local jiyuan = fk.CreateSkill{
  name = "iberia__jiyuan",
}

Fk:loadTranslationTable{
  [jiyuan.name] = "急援",
  [":"..jiyuan.name] = "当需要对其他角色使用【桃】时，你可以令当前回合角色展示一张手牌，然后你可以弃置一张类型相同的牌并视为使用之。",

  ["#"..jiyuan.name] = "急援：可以令当前回合角色展示一张手牌，然后可以弃置一张类型相同的牌并视为使用【桃】",
  ["#"..jiyuan.name.."-show"] = "急援：展示一张手牌",
  ["#"..jiyuan.name.."-discard"] = "急援：可以弃置一张类型相同的牌并视为使用【桃】",
}

jiyuan:addEffect("viewas", {
  anim_type = "support",
  prompt = "#"..jiyuan.name,
  pattern = "peach",
  card_filter = function (self, player, to_select, selected)
    return false
  end,
  view_as = function (self, player, cards)
    local peach = Fk:cloneCard("peach")
    peach.skillName = jiyuan.name
    return peach
  end,
  before_use = function (self, player, use)
    local room = player.room
    local cards = room:askToCards(room.current, {
      max_num = 1,
      min_num = 1,
      skill_name = jiyuan.name,
      cancelable = false,
      prompt = "#"..jiyuan.name.."-show"
    })
    room:showCards(cards, room.current)
    if player.dead then return jiyuan.name end

    if not room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      skill_name = jiyuan.name,
      cancelable = true,
      pattern = ".|.|.|.|.|" .. Fk:getCardById(cards[1]):getTypeString(),
      prompt = "#"..jiyuan.name.."-discard",
    }) then
      return jiyuan.name
    end
  end,
  enabled_at_play = function (self, player)
    return not Fk:currentRoom().current:isKongcheng()
  end,
  enabled_at_response = function (self, player, response)
    return not Fk:currentRoom().current:isKongcheng() and not response
  end,
})

jiyuan:addEffect("prohibit", {
  is_prohibited = function (self, from, to, card)
    return from:hasSkill(jiyuan.name) and to == from and card.skillName == jiyuan.name
  end,
})

return jiyuan